<?php

namespace app\common\validate;


use app\common\exception\ApiException;
use think\Validate;

class BaseValidate extends Validate {
    public function goCheck($scene = '') {
        $params = request()->param();
        $result = $this->check($params, $this->rule, $scene);
        if (!$result) {
            throw new ApiException($this->error, 200, 1);
        } else {
            return true;
        }
    }

    protected function isPositiveInteger($value, $rule = '', $data = '', $field = '') {
        if (is_numeric($value) && is_int($value + 0) && ($value + 0) > 0) {
            return true;
        } else {
            return false;
        }
    }
}